Imports System.Windows.Forms
Imports dao
 Imports System.Data
Imports DTO
Public Class CTDIEMBus
Inherits AbstractBus
 Public Sub New()
 End Sub
 Public Sub New(ByVal ConnectionString As KetNoiDto)
 ketnoi = ConnectionString
 End Sub
 #Region "Xử Lý" 
 Public Sub Them(ByVal Dto As CTDIEMDto)
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.Them(Dto)
 End Sub
 Public Sub Xoa( ByVal IDCTDIEM As System.Int32)
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.xoa(IDCTDIEM)
 End Sub
 Public Sub sua(ByVal Dto As CTDIEMDto)
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.sua(Dto)
 End Sub
 #End Region 
 Public Function LayBangTable() As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 dao.laybang()
 Return Dao
 End Function
 Public Function LayBangTableIlist() As IList
 Dim Dao As New CTDIEMDao(ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoCTDIEM As CTDIEMdto = LayBangDTo(i, Dao) 
 aList.Add(dtoCTDIEM)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableSQL(ByVal sql As string) As DataTable
 Dim Dao As New  AbstractDao(sql,sql,ketnoi)
 Return Dao
 End Function
 Public Sub suaIDDIEM( ByVal IDDIEM as System.Int32, ByVal IDCTDIEM As System.Int32 )
 Dim dao As New CTDIEMDao(ketnoi)
 dao.suaIDDIEM(IDDIEM,IDCTDIEM)
 End Sub 
 Public Sub suaDIEM( ByVal DIEM as System.Int32, ByVal IDCTDIEM As System.Int32 )
 Dim dao As New CTDIEMDao(ketnoi)
 dao.suaDIEM(DIEM,IDCTDIEM)
 End Sub 
 Public Sub suaLOAIDIEM( ByVal LOAIDIEM as System.Int32, ByVal IDCTDIEM As System.Int32 )
 Dim dao As New CTDIEMDao(ketnoi)
 dao.suaLOAIDIEM(LOAIDIEM,IDCTDIEM)
 End Sub 
 Public Sub suaTRANGTHAI( ByVal TRANGTHAI as System.Int32, ByVal IDCTDIEM As System.Int32 )
 Dim dao As New CTDIEMDao(ketnoi)
 dao.suaTRANGTHAI(TRANGTHAI,IDCTDIEM)
 End Sub 
 Public Sub suaGHICHU( ByVal GHICHU as System.String, ByVal IDCTDIEM As System.Int32 )
 Dim dao As New CTDIEMDao(ketnoi)
 dao.suaGHICHU(GHICHU,IDCTDIEM)
 End Sub 
 Public Function LayBangTable( ByVal IDCTDIEM As System.Int32) As DataTable
 Dim Dao As New CTDIEMDao(IDCTDIEM,ketnoi)
 Return Dao
 End Function
 Public Function LayBangTableIlist( ByVal IDCTDIEM As System.Int32) As IList
 Dim Dao As New CTDIEMDao(IDCTDIEM,ketnoi)
 Dim aList As New ArrayList 
 For i As Integer = 0 To Dao.Rows.Count - 1 
 Dim dtoCTDIEM As CTDIEMdto = LayBangDTo(i, Dao) 
 aList.Add(dtoCTDIEM)
 Next 
 Return aList 
 End Function
 Public Function LayBangTableTheoIDCTDIEM (ByVal IDCTDIEM As System.Int32) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoIDCTDIEM(IDCTDIEM)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDCTDIEM (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoIDCTDIEM(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDCTDIEM (ByVal IDCTDIEM As System.Int32) 
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.XOABangTheoIDCTDIEM(IDCTDIEM)
 End sub
 Public Function LayBangTableTheoIDDIEM (ByVal IDDIEM As System.Int32) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoIDDIEM(IDDIEM)
 Return Dao
 End Function
 Public Function LayBangTableTheoIDDIEM (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoIDDIEM(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoIDDIEM (ByVal IDDIEM As System.Int32) 
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.XOABangTheoIDDIEM(IDDIEM)
 End sub
 Public Function LayBangTableTheoDIEM (ByVal DIEM As System.Int32) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoDIEM(DIEM)
 Return Dao
 End Function
 Public Function LayBangTableTheoDIEM (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoDIEM(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoDIEM (ByVal DIEM As System.Int32) 
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.XOABangTheoDIEM(DIEM)
 End sub
 Public Function LayBangTableTheoLOAIDIEM (ByVal LOAIDIEM As System.Int32) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoLOAIDIEM(LOAIDIEM)
 Return Dao
 End Function
 Public Function LayBangTableTheoLOAIDIEM (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoLOAIDIEM(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoLOAIDIEM (ByVal LOAIDIEM As System.Int32) 
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.XOABangTheoLOAIDIEM(LOAIDIEM)
 End sub
 Public Function LayBangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(TRANGTHAI)
 Return Dao
 End Function
 Public Function LayBangTableTheoTRANGTHAI (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoTRANGTHAI(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoTRANGTHAI (ByVal TRANGTHAI As System.Int32) 
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.XOABangTheoTRANGTHAI(TRANGTHAI)
 End sub
 Public Function LayBangTableTheoGHICHU (ByVal GHICHU As System.String) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoGHICHU(GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU_like (ByVal GHICHU As System.String ) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoGHICHU_like (GHICHU)
 Return Dao
 End Function
 Public Function LayBangTableTheoGHICHU (ByVal ARRAY1 As ArrayList) As DataTable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangTheoGHICHU(ARRAY1)
 Return Dao
 End Function
 Public sub XOAbangTableTheoGHICHU (ByVal GHICHU As System.String) 
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.XOABangTheoGHICHU(GHICHU)
 End sub
 Public Function LayBangDTo( ByVal IDCTDIEM As System.Int32) As CTDIEMdto
 Dim Dao As New CTDIEMDao(IDCTDIEM, ketnoi)
 Dim dto As New CTDIEMdto
 If Dao.Rows.Count<= 0 then Return dto
 Try
 If IsDBNull(Dao.Rows(0)("IDCTDIEM")) = False Then
 Dto.IDCTDIEM = Dao.Rows(0)("IDCTDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTDIEM.IDCTDIEM")) = False Then
 Dto.IDCTDIEM = Dao.Rows(0)("CTDIEM.IDCTDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(0)("IDDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTDIEM.IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(0)("CTDIEM.IDDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("DIEM")) = False Then
 Dto.DIEM = Dao.Rows(0)("DIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTDIEM.DIEM")) = False Then
 Dto.DIEM = Dao.Rows(0)("CTDIEM.DIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("LOAIDIEM")) = False Then
 Dto.LOAIDIEM = Dao.Rows(0)("LOAIDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTDIEM.LOAIDIEM")) = False Then
 Dto.LOAIDIEM = Dao.Rows(0)("CTDIEM.LOAIDIEM")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTDIEM.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(0)("CTDIEM.TRANGTHAI")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("GHICHU")
 End if
Catch ex As Exception
End Try
 Try
 If IsDBNull(Dao.Rows(0)("CTDIEM.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(0)("CTDIEM.GHICHU")
 End if
Catch ex As Exception
End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal i As Integer, ByVal dao As DataTable) As CTDIEMdto
 Dim dto As New CTDIEMdto
 If Dao.Rows.Count<=0 then Return dto
 Try
 If IsDBNull(Dao.Rows(i)("IDCTDIEM")) = False Then
 Dto.IDCTDIEM = Dao.Rows(i)("IDCTDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTDIEM.IDCTDIEM")) = False Then
 Dto.IDCTDIEM = Dao.Rows(i)("CTDIEM.IDCTDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(i)("IDDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTDIEM.IDDIEM")) = False Then
 Dto.IDDIEM = Dao.Rows(i)("CTDIEM.IDDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("DIEM")) = False Then
 Dto.DIEM = Dao.Rows(i)("DIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTDIEM.DIEM")) = False Then
 Dto.DIEM = Dao.Rows(i)("CTDIEM.DIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("LOAIDIEM")) = False Then
 Dto.LOAIDIEM = Dao.Rows(i)("LOAIDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTDIEM.LOAIDIEM")) = False Then
 Dto.LOAIDIEM = Dao.Rows(i)("CTDIEM.LOAIDIEM")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTDIEM.TRANGTHAI")) = False Then
 Dto.TRANGTHAI = Dao.Rows(i)("CTDIEM.TRANGTHAI")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("GHICHU")
 End if
 Catch ex As Exception
 End Try
 Try
 If IsDBNull(Dao.Rows(i)("CTDIEM.GHICHU")) = False Then
 Dto.GHICHU = Dao.Rows(i)("CTDIEM.GHICHU")
 End if
 Catch ex As Exception
 End Try
 Return dto
 end function
 Public Function LayBangDTo(ByVal dong As Integer, ByVal dao As DataGridView) As CTDIEMdto
 Dim dto As New CTDIEMdto
 If dao.Rows.Count <= 0 Then Return dto
 For cot As Integer = 0 To dao.Columns.Count - 1
 Try
 Dto.HoTro(dao.Columns(cot).DataPropertyName, dao.Item(cot, dong).Value)
 Catch ex As Exception
 End Try
 Next
 Return Dto
 End Function
 Public Function layBangNhieuTable() as Datatable
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.layBangNhieuTable()
 Return Dao
 End Function
 Public Sub Taotable()
 Dim Dao As New CTDIEMDao(ketnoi)
 Dao.TaoTable()
 End Sub
 End Class

